﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Shapes;
using System.Windows.Media;
using System.Windows;
using System.Windows.Media.Animation;
using System.Windows.Controls;

namespace MigratorUI.RenderEngine
{
    
    class ActiveAnimation : Animation
    {

        public ActiveAnimation(Sprite sprite, bool isRepeatAnimation)
            : base(sprite,isRepeatAnimation)
        {   
        }

        protected override System.Windows.Media.Geometry DefiningGeometry
        {
            get { return this.ellipse; }
        }

        #region Animation Members

        protected override void CreateShape()
        {
            this.ellipse = new EllipseGeometry();
            this.ellipse.Center = new System.Windows.Point(Sprite.Position.X + (Sprite.Image.Width / 2), Sprite.Position.Y + (Sprite.Image.Height / 2));
            this.ellipse.RadiusX = Sprite.Radius;
            this.ellipse.RadiusY = Sprite.Radius;

            //Fill and Opacity
            this.Fill = Brushes.Cyan;
            this.Opacity = 0.50;
            this.OpacityMask = Brushes.Red;

            //Stroke
            this.Stroke = Brushes.Black;
            this.StrokeThickness = 2;
 
        }

      /*  public override Point GetShapePositionInCanvas()
        {
            this.position.X = Canvas.GetLeft(this);
            this.position.Y = Canvas.GetTop(this);
            return this.position;
        }*/

        public override void RunAnimation()
        {
            DoubleAnimation animation = new DoubleAnimation();
            animation.From = 0.10;
            animation.To = 0.50;
            animation.Duration = new Duration(TimeSpan.FromSeconds(3));
            animation.RepeatBehavior = RepeatBehavior.Forever;
            animation.AutoReverse = true;
            animation.Completed += new EventHandler(ActiveAnimationCompleted);
            this.BeginAnimation(Shape.OpacityProperty, animation);
        }

        #endregion

        private void ActiveAnimationCompleted(object sender, EventArgs e)
        {
            base.AnimationCompleted();
        }


        private EllipseGeometry ellipse;



       
    }
}
